export class zoomApi {
    constructor() {
        this.preUrl = "https://api.zoom.us/v2";
        this.authorization = 'xxxxxx';
    }

    zoomUrl(apiUrl) {
        return this.preUrl + apiUrl;
    }

    createMeeting(userId, data) {
        let apiUrl = `/users/${userId}/meetings`;
        let headers = {
            'authorization': this.authorization,
            'Content-Type': 'application/json'
        };
        return kintone.proxy(this.zoomUrl(apiUrl), 'POST', headers, data);
    }

    //kintone is not support "PATCH" methd.
    updateMeeting(meetingId, data) {
        let apiUrl = `/meetings/${meetingId}`;
        let headers = {
            'authorization': this.authorization,
            'Content-Type': 'application/json'
        };
        return kintone.proxy(this.zoomUrl(apiUrl), 'PATCH', headers, data);
    }

    deleteMeeting(meetingId) {
        let apiUrl = `meetings/${meetingId}`;
        let headers = {
            'authorization': this.authorization
        };
        return kintone.proxy(this.zoomUrl(apiUrl), 'DELETE', headers, '');
    }
}